package com.googlecode.microanalyst.palette.model;

import org.eclipse.draw2d.geometry.Dimension;
import org.eclipse.swt.graphics.Image;

import com.googlecode.microanalyst.designer.model.AnalysisElement;
import com.googlecode.microanalyst.designer.model.property.PropertyHandler;
import com.googlecode.microanalyst.palette.i18n.PaletteMessages;

public class Output extends AnalysisElement {

	private static final long serialVersionUID = 1L;

	public static final String ICON_PATH = "icons/output16.gif";//$NON-NLS-1$

	public static final String INPUT = "in";

	public static Image ICON = createImage(Output.class, ICON_PATH);

	private String filename;

	public Output() {
		this.size.width = -1;
		this.size.height = -1;
		this.filename = "";
	}


	protected Output(String filename) {
		this();
		this.filename = filename;
	}

	@Override
	public Image getIconImage() {
		return ICON;
	}

	@Override
	public Dimension getSize() {
		return new Dimension(size.width, size.height);
	}

	@Override
	public void setSize(Dimension size) {
	}

	public String getFilename() {
		return filename;
	}

	public void setFilename(String name) {
		String old = this.filename;
		this.filename = name;
		firePropertyChange(OutputProperties.PROPERTY_FILENAME, old, name); 
	}

	@Override
	public String toString() {
		return PaletteMessages.Palette_Tool_Output;
	}

	@Override
	public Object clone() {
		return new Output(filename);
	}

	@Override
	public PropertyHandler getPropertyHandler() {
		return new OutputProperties(this);
	}

}
